<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<title>修改登录密码</title>
<link th:href="@{/ksdH5/css/public/mui/mui.css}" rel="stylesheet"/>
<script th:src="@{/ksdH5/js/public/mui/mui.min.js}"></script>
<script th:src="@{/ksdH5/js/public/jquery.min.js}"></script>
<script th:src="@{/ksdH5/js/public/public.js}"></script>
<link th:href="@{/ksdH5/css/setUp/changeLoginPassword.css}" rel="stylesheet"/>
</head>
<body>
<div class="mui-content">
	<div class="headerBox">
		<a href="javascript:history.go(-1);" class="headerBox_left"><img th:src="@{/ksdH5/img/planList/fanhuiBnt.png}"></a>
		<span>修改登录密码</span>
	</div>
	<div class="changeLoginPassword">
		<div class="changeLoginPassword_inputBox">
			<span>手机号</span>
			<em style="font-weight: bold;" th:text="${phone}"></em>
		</div>
		<div class="changeLoginPassword_inputBox">
			<span>旧密码</span>
			<input type="password" id="old_password" placeholder="请输入原始密码" />
		</div>
		<div class="changeLoginPassword_inputBox">
			<span>新密码</span>
			<input type="password" id="new_password1" placeholder="请输入新密码" />
		</div>
		<div class="changeLoginPassword_inputBox">
			<span>确认密码</span>
			<input type="password" id="new_password2"  placeholder="请再次输入新密码" />
		</div>
	</div>
	<button class="changeLoginPassword_bnt" onclick="updateLoginPWD()">确认</button>
</div>
</body>
<script th:inline="javascript">
	//获得项目根路径
	var ctx = [[@{/}]];
</script>
<script type="text/javascript">
var prefix = ctx+"h5";
mui.init({
	swipeBack:true
})
//提交修改密码
function updateLoginPWD(){
	var oldPassword = $.trim($("#old_password").val());
	if(oldPassword.lengt<6){
		mui.toast("密码不得小于6位",{ duration:'long'});
		return;
	}
	var password1 = $.trim($("#new_password1").val());
	if(password1.length<6){
		mui.toast("密码不得小于6位",{ duration:'long'});
		return;
	}
	var password2 = $.trim($("#new_password2").val());
	if(password1 != password2){
		mui.toast("两次密码不一致",{ duration:'long'});
		return;
	}
	
	if(oldPassword==password1){
		mui.toast("新旧密码不能相同",{ duration:'long'});
		return;
	}
	$.ajax({
		url : prefix +"/updateLoginPwd",
		dataType : "json",
		type : "POST",
		data:{
			"newPasswd":password1,
			"oldPasswd":oldPassword
		},
		success : function(re) {
			if(re.status=="out"){
				location.href= prefix + '/login';
			}
			if(re.status=="SUCCESS"){
				mui.toast(re.msg,{ duration:'long'});
				setTimeout(function(){
					location.href= prefix + '/login';
				},3000)
			}else {
				mui.toast(re.msg,{ duration:'long'});
			}
		}
	});

}
</script>

</html>
